<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>主页</title>
</head>
<body>
    <div class="row">
        <h1>当前用户为：<span id="username"/></h1>
    </div>

    <script src="https://code.jquery.com/jquery-3.6.1.min.js"></script>
    <script>
        var username = document.querySelector("#username");
        $.ajax({
            type: 'get',
            url: 'info',
            success: function (body) {
                if (body.status == 0) {
                    username.innerHTML = body.data;
                }else {
                    alert(body.message);
                    location.assign("login.html")
                }
            }
        });
    </script>
</body>
</html>